/********************************
 .h for sd card read protocal
 ee_hqxaa, Hilda
********************************/



#ifndef __SD_h__
#define __SD_h__

#define uint8	unsigned char
#define int8	signed char
#define uint16	unsigned int
#define	int16	signed int
#define uint32	unsigned long
#define int32	signed long

#define SD_PORT		PORTB			// use portB to communicate SD
#define	SD_CS_PIN	0				// mega128 PortB.0 ss
#define DDR_INI() DDRB|=_BV(0)|_BV(1)|_BV(2)		// SS, MOSI, SCK for m128 portB, write
#define SPI_CS_Assert() SD_PORT &= ~_BV(SD_CS_PIN)	//active low SS=0
#define SPI_CS_Deassert() SD_PORT |= _BV(SD_CS_PIN) // SS=1

extern void SD_Init(void);
extern uint8 SD_Reset(void);
extern uint8 SD_ReadSingleBlock(uint32 sector, uint8*buffer);
//extern uint8 SD_WriteSingleBlock(uint32 sector, uint8*buffer);
extern uint32 SD_ReadCapacity(void);
extern void SPI_High(void);
extern void SPI_Low(void);

#endif
